<template>
	<CreateFields
		ref="crmForm"
		:col="col"
		:source-model="sourceModel"
		class="search-box"
	/>
</template>

<script>
import { fieldQuerySearch } from '@/api/customermanagement/common.js'
import crmTypeModel from '@/views/customermanagement/model/crmTypeModel.js'
export default {
	components: {
		CreateFields: () => import('@/components/CreateFields')
	},
	props: {
		crmType: String
	},
	data() {
		return {
			sourceModel: [],
			col: 2
		}
	},
	watch: {
		crmType: {
			handler(val) {
				this.sourceModel = []
				this.getSearchFields()
			},
			immediate: true
		}
	},
	methods: {
		async getSearchFields() {
			const { data } = await fieldQuerySearch({
				label: crmTypeModel[this.crmType]
			}).catch((e) => console.log(e))
			this.sourceModel = data
			this.$emit('field-geted')
		},
		getSubmitValue() {
			return this.$refs.crmForm.getSubmiteParams()
		}
	}
}
</script>

<style scoped="scoped" lang="scss">
.search-box {
	padding: 0 !important;
}
.search-box ::v-deep .crm-create-item {
	padding: 0 10px 0 0 !important;
	display: flex;
	max-width: none;
	flex-wrap: nowrap;
	align-items: center;
	.el-form-item__label {
		flex: 0 0;
		white-space: nowrap;
		margin-right: 10px;
		padding: 0;
		color: #373737;
		font-size: 13px;
	}
	.el-form-item__content {
		flex: 1 1;
		// min-width: 190px;
	}
}
</style>
